home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
basic
/
vbhelp.exe
/
HELP.BAS
< prev
next >
Wrap
BASIC Source File
|
1992-08-19
|
28KB
|
706 lines
' ------------------------------------------------------------------------
' Visual Basic for MS-DOS Help Toolkit
'
' The Help Toolkit (HELP.BAS, HELPF.FRM, and HELPUTIL.FRM)
' makes it easy to add a hypertext Help system to your
' applications.
'
' To use the Help Toolkit in your programs, include
' HELP.BAS, HELPF.FRM, and HELPUTIL.FRM in your program or
' use the supplied library (HELP.LIB, HELPA.LIB - AltMath
' version) and Quick library (HELP.QLB) and call the
' appropriate routines to load and display your help topics.
' Forms and code modules that call Help routines
' must include HELP.BI ('$INCLUDE: 'HELP.BI').
'
' Help files can be written in any ASCII text editor or
' in Visual Basic itself. Refer to the sample Help file
' HELPDEMO.TXT as an example of the Help file format.
' HELPDEMO.TXT also contains full information on creating
' Help files and using the Help Toolkit to display and
' navigate them.
'
' The Help ToolKit consists of the following routines:
' HelpRegister - initializes the Help system and loads Help file
' HelpShowTopic - displays specified Help topic
' HelpClose - closes Help file
' HelpSetOptions - sets Help display options
' HelpSearch - invokes Help Search dialog to enable topic search
' Detailed descriptions of these procedures are contained
' in the comment headers above each.
'
' Copyright (C) 1982-1992 Microsoft Corporation
'
' You have a royalty-free right to use, modify, reproduce
' and distribute the sample applications and toolkits provided with
' Visual Basic for MS-DOS (and/or any modified version)
' in any way you find useful, provided that you agree that
' Microsoft has no warranty, obligations or liability for
' any of the sample applications or toolkits.
' ------------------------------------------------------------------------
' Include file containing procedure declarations.
'$INCLUDE: 'HELP.BI'
'$FORM frmHelpUtils ' Form for Search, History, and Change dialogs
'$FORM frmHelpMain ' Help window
TYPE IndexType ' Used to index Help topics
StartFilePtr AS LONG ' Position within the topic's file
NumLines AS INTEGER ' Number of lines in the Help topic
END TYPE
TYPE PointType
X AS INTEGER ' Horizontal location
Y AS INTEGER ' Vertical location
END TYPE
' Variables common to HELP.BAS, HELPF.FRM, and HELPUTIL.FRM.
COMMON SHARED /HelpLib/ DialogBackcolor AS INTEGER ' Background color for Help dialog boxes (Search, Copy, History)
COMMON SHARED /HelpLib/ DialogForecolor AS INTEGER ' Foreground color for Help dialog boxes (Search, Copy, History)
' Variables common to HELP.BAS and HELPF.FRM.
COMMON SHARED /HelpLib/ Topic() AS STRING ' Lines of the current Help topic
COMMON SHARED /HelpLib/ LeftChar AS INTEGER ' Leftmost character of the Help topic given the horizonal scroll position
COMMON SHARED /HelpLib/ StartLine AS INTEGER ' Top line of the Help topic given the vertical scroll position
COMMON SHARED /HelpLib/ MaxLineLen AS INTEGER ' Longest line of the Help topic
COMMON SHARED /HelpLib/ HelpIndexPtr() AS IndexType ' Table that stores data about each Help topic
COMMON SHARED /HelpLib/ HelpIndexTopics() AS STRING ' Array of Help topic names. Used with the HelpIndexPtr table.
COMMON SHARED /HelpLib/ HelpFileNum AS INTEGER ' Logical file number assigned to the Help file by HelpRegister
COMMON SHARED /HelpLib/ HelpTopicStack() AS STRING ' Array of the last 20 Help topics shown
COMMON SHARED /HelpLib/ HelpTopicStackPtr AS INTEGER ' Number of topics in the HelpTopicStack
COMMON SHARED /HelpLib/ TopicFound AS STRING ' The Help topic being shown
COMMON SHARED /HelpLib/ MaxHistoryStack AS INTEGER ' Maximum allowed size of the HelpTopicStack. HelpRegister sets to 20.
COMMON SHARED /HelpLib/ UnloadOnClose AS INTEGER ' Flag that determines if closing the Help form terminates the Help system.
COMMON SHARED /HelpLib/ KillHelp AS INTEGER ' Flag that HelpClose sets to terminate the Help form
COMMON SHARED /HelpLib/ CursorPos AS PointType ' Position of the currently selected Help link within a topic
COMMON SHARED /HelpLib/ ButtonBarHeight AS INTEGER ' Number of lines to reserve at the top of the form for the button bar. 0 or 3.
COMMON SHARED /HelpLib/ CloseOnEscape AS INTEGER ' If TRUE, pressing ESC will close the Help window
DEFINT A-Z
CONST FALSE = 0
CONST TRUE = NOT FALSE
CONST TabSpaces = 4 ' Number of spaces that a TAB represents
DIM SHARED SelectedTopicColor AS INTEGER ' The foreground color of Help links
DIM SHARED SpaceString AS STRING ' A string of blank spaces used by the HelpPrintText procedure
DIM SHARED HelpFileName AS STRING ' Help file name.
'----------------------------------------------------
' Sample usage of the Help Toolkit. This code is
' only executed if HELP.BAS is the start-up file.
' Parameter information for each Help procedure is
' contained in the header comments for the procedure.
'----------------------------------------------------
' Set the title bar background color to magenta (5),
' the screen background color to blue (1), and the
' access key color to red (4).
screen.controlpanel(16) = 5
screen.controlpanel(5) = 1
screen.controlpanel(0) = 4
' Initialize the Help system and load specified Help file.
' HelpLoaded% returns whether or not the Help file was
' loaded successfully.
HelpRegister "HELPDEMO.TXT", HelpLoaded%
' HelpLoaded% will be FALSE if HelpRegister fails.
IF HelpLoaded% THEN
' Set Help color and button display options.
' Calls to this routine are optional as Help will
' use its defaults if this call is ommitted.
HelpSetOptions 3, 0, 7, 0, 7, 11, 2
' Show the table of contents topic for the Help file.
' Help will remain visible until window is closed
' by the user. Help topics can be changed by the user
' once the Help window is made visible with the first
' topic displayed.
HelpShowTopic "Contents"
END IF
' Help close and unload routine.
'
' Closes help file and unloads help form.
' This routine should be called when the
' parent application terminates. If the parent
' routine has no END statement (e.g. it stops when
' the user closes the last form), the last Form_Unload
' must call this procedure. Otherwise, the application
' will not end because frmHelpMain will still be loaded.
'
SUB HelpClose ()
KillHelp = TRUE
UNLOAD frmHelpMain
END SUB
' Internal routine that returns the greater of two integers.
'
FUNCTION HelpMax (int1 AS INTEGER, int2 AS INTEGER) AS INTEGER
IF int1 > int2 THEN
HelpMax = int1
ELSE
HelpMax = int2
END IF
END FUNCTION
' Internal routine that returns the lower of two integers.
'
FUNCTION HelpMin (int1 AS INTEGER, int2 AS INTEGER) AS INTEGER
IF int1 > int2 THEN
HelpMin = int2
ELSE
HelpMin = int1
END IF
END FUNCTION
' Help topic print routine.
'
' Internal routine that prints Help topic text.
' Called when a topic is first shown and when
' the form is scrolled.
'
' Parameters:
' TopLine - The first element (line) of the topic
' array to be displayed.
' LeftPos - The first character of each topic line
' to be displayed.
'
SUB HelpPrintText (TopLine AS INTEGER, LeftPos AS INTEGER)
MaxLines = UBOUND(Topic) ' The number of lines in the Help topic.
IF TopLine > MaxLines THEN EXIT SUB
LastPrintedLine = TopLine + frmHelpMain.pctBackground.ScaleHeight ' The last line of the Help topic that will be printed.
IF LastPrintedLine > MaxLines THEN
' Ensures that the routine does not attempt to print more lines than the topic size
LastPrintedLine = MaxLines
END IF
blanklines = frmHelpMain.pctBackground.ScaleHeight - (LastPrintedLine - TopLine - ButtonBarHeight) ' Number of blank lines on the form.
FormWidth = frmHelpMain.pctBackground.ScaleWidth ' Local variable copy of the form width. Used to minimize property access.
frmHelpM